﻿using System;

namespace Message.Base
{
    /// <summary>
    /// 系统消息抽象类
    /// </summary>
    public abstract class BaseSystemMessage : BaseMessage
    {
        protected BaseSystemMessage(int messageId) : base(messageId) { }

        public override int GetBytesLength() => 8;
        public override byte[] GetBytes()
        {
            byte[] buffer = new byte[GetBytesLength()];
            //4字节ID
            BitConverter.GetBytes(MessageID).CopyTo(buffer, 0);
            //4字节长度
            BitConverter.GetBytes(GetBytesLength()).CopyTo(buffer, 4);
            return buffer;
        }
        
        //系统消息不需要写入
        public override void WriteIn(byte[] buffer, int beginIndex, int length)
        {
            throw new NotImplementedException();
        }
    }
}
